package cn.net.lwj.common.util;

//import cn.net.withub.common.utils.FileUtil;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.SocketException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPReply;
import sun.misc.BASE64Encoder;

public class FtpUtils {

    private String ip = CommonProperties.FTP_IP;
    private Integer port = CommonProperties.FTP_PORT;
    private String user = CommonProperties.FTP_USER;
    private String pwd = CommonProperties.FTP_PWD;

    public FtpUtils() {
    }

    public FtpUtils(String ip, Integer port, String user, String pwd) {
        this.ip = ip;
        this.port = port;
        this.user = user;
        this.pwd = pwd;
    }


    /**
     * 获取FTPClient
     * @return
     * @throws Exception
     */
    public FTPClient getFTPClient() throws Exception {
        FTPClient ftpClient = new FTPClient();
        if (connectServer(ftpClient, ip, port, user, pwd)) {
            return ftpClient;
        } else {
            return null;
        }
    }

    /**
     * 连接FTP
     * @param ftpClient
     * @param ftpIp
     * @param ftpPort
     * @param ftpUser
     * @param ftpPwd
     * @return
     * @throws Exception
     */
    public boolean connectServer(FTPClient ftpClient, String ftpIp, Integer ftpPort, String ftpUser, String ftpPwd) throws Exception {
        boolean flag = false;
        ftpClient.connect(ip, port);
        ftpClient.login(user, pwd);
        //后三项以前没加,待学习
        ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);//设置文件类型（二进制）
        //增大缓存区 20211213 提高上传下载速度
        ftpClient.setBufferSize(1024 * 1024 * 10);
        ftpClient.enterLocalPassiveMode();
        ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
        //lwj 有的设置的GBK,这个应该和ftp服务器有关系,  而且这个编码设置不能放在前面,否则得不到流
        ftpClient.setControlEncoding("UTF-8");//中文支持
        ftpClient.setDataTimeout(60000);
        //是否成功登录服务器
        int reply = ftpClient.getReplyCode();
        if (!FTPReply.isPositiveCompletion(reply)) {
            ftpClient.disconnect();
        } else {
            flag = true;
        }
        return flag;
    }


    /**
     * 从FTP服务器下载文件 法一
     * @param ftpUrl ftp上的文件路径 eg:/
     * @param wjmc  ftp上的文件名称  eg:test.png
     * @param localWjlj 本地文件路径  需要加上文件夹和文件名  如:eg:\test\1111\1.png
     */
    public void download(String ftpUrl, String wjmc, String localWjlj) {
        FTPClient ftpClient = new FTPClient();
        InputStream inputStream = null;
        try {
            ftpClient = getFTPClient();
            //ftpClient.connect(ip, port);
            //ftpClient.login(user, pwd);
            //ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
            //ftpClient.enterLocalPassiveMode();
            //ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
            ////lwj connectServer方法里设置的GBK,这个应该和ftp服务器有关系,
            //ftpClient.setControlEncoding("UTF-8");
            ////是否成功登录服务器
            //int reply = ftpClient.getReplyCode();
            //if (!FTPReply.isPositiveCompletion(reply)) {
            //    ftpClient.disconnect();
            //}
            //connectServer(ftpClient, ip, port, user, pwd);
            //跳转到指定目录
            ftpClient.changeWorkingDirectory(ftpUrl);
            //5.遍历下载的目录
            FTPFile[] fs = ftpClient.listFiles();
            for (FTPFile ff : fs) {
                //解决中文乱码问题，两次解码
                //如果是fileZilla中文版 ,那么此处用中文解码好像反而有问题,要么就两处同时对应编码
                //byte[] bytes = ff.getName().getBytes("iso-8859-1");
                //String fileName = new String(bytes, "utf-8");
                //fileZilla中文版时,把传入的中文名用同样的方法转换了在比较可行,其他待测试
                String fileName = toFtpFilename(ff.getName());
                if (toFtpFilename(wjmc).equals(fileName)) {//fileZilla时
                //if (wjmc.equals(fileName)) {//其他ftp时
                    //inputStream = ftpClient.retrieveFileStream(fileName);
                    inputStream = ftpClient.retrieveFileStream(fileName);
                    FileOutputStream fos = new FileOutputStream(new File(localWjlj));
                    byte[] b = new byte[1024];
                    int len = 0;
                    while ((len = inputStream.read(b)) != -1) {
                        fos.write(b, 0, len);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (ftpClient.isConnected()) {
                try {
                    ftpClient.disconnect();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (null != inputStream) {
                try {
                    inputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    /**
     * 从FTP服务器下载文件 法二
     * 此方法代码量少些
     * @param ftpPath   FTP服务器中文件所在路径 格式： ftptest/aa
     * @param localPath 下载到本地的位置 格式：H:/download
     * @param fileName  文件名称 :下载的本地文件命名名称和ftp服务器上的目标文件名称
     */
    public void downloadFtpFile(String ftpPath, String fileName, String localPath) {
        FTPClient ftpClient = null;
        try {
            ftpClient = getFTPClient();
            //跳转到指定目录
            ftpClient.changeWorkingDirectory(ftpPath);
            File localFile = new File(localPath + File.separatorChar + fileName);
            OutputStream os = new FileOutputStream(localFile);
            //ftpClient.retrieveFile(fileName, os);
            //处理中文
            ftpClient.retrieveFile(toFtpFilename(fileName), os);
            os.close();
            ftpClient.logout();
        } catch (FileNotFoundException e) {
            System.out.println("没有找到" + ftpPath + "文件");
            e.printStackTrace();
        } catch (SocketException e) {
            System.out.println("连接FTP失败.");
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
            System.out.println("文件读取错误。");
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 上传文件
     * @param ftpPath FTP服务器中文件所在路径 格式： ftptest/aa
     * @param ftpFileName ftp文件名称  aa.jpg
     * @param input 文件流 new FileInputStream(file);
     * @return 路径
     */
    public String uploadFile(String ftpPath, String ftpFileName, InputStream input) {
        FTPClient ftpClient = null;
        String serverPath = "";
        try {
            ftpClient = getFTPClient();
            //ftpClient.setControlEncoding("GBK"); // 中文支持  UTF-8乱码
            //ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);//设置文件类型（二进制）
            //这个方法的意思就是每次数据连接之前，ftp client告诉ftp server开通一个端口来传输数据。为什么要这样做呢，因为ftp server可能
            // 每次开启不同的端口来传输数据，但是在linux上，由于安全限制，可能某些端口没有开启，所以就出现阻塞。
            ftpClient.enterLocalPassiveMode();
            //changeWorkingDirectory比较奇怪 120.79.157.134下 必须在目录存在的情况下才会切换成功,在ftp根目录下切换  一层目录好像也不能切换成功   10.149.0.57下又正常
            changeMakeWorkingDir(ftpPath, ftpClient);
            //此处,如果ftpFileName是中文,将会异常,需要处理
            //ftpClient.storeFile(ftpFileName, input);
            ftpClient.storeFile(toFtpFilename(ftpFileName), input);
            input.close();
            ftpClient.logout();
            serverPath = ftpPath + ftpFileName;
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (ftpClient != null && ftpClient.isConnected()) {
                try {
                    ftpClient.disconnect();
                } catch (IOException ignored) {
                }
            }
        }
        return serverPath;
    }

    /**
     * 上传本地文件
     * @param ftpPath FTP服务器中文件所在路径 格式： ftptest/aa
     * @param ftpFileName ftp文件名称  aa.jpg
     * @param localPath 本地路径  E://test.jpg;
     * @return
     */
    public String uploadLocalFile(String ftpPath, String ftpFileName, String localPath) throws FileNotFoundException {
        InputStream input = new FileInputStream(new File(localPath));
        return uploadFile(ftpPath, ftpFileName, input);
    }

    /**
     *
     * @param ftpPath FTP服务器中文件所在路径+文件名 格式： ftptest/aa/test.txt
     * @param localPath 本地路径  E://test.jpg;
     * @return
     * @throws FileNotFoundException
     */
    public String uploadLocalFile(String ftpPath, String localPath) throws FileNotFoundException {
        InputStream input = new FileInputStream(new File(localPath));
        int index = 0;
        if (ftpPath.contains("/")) {
            index = ftpPath.lastIndexOf("/");
        }else {
            index = ftpPath.lastIndexOf("\\");
        }
        String path = ftpPath.substring(0, index);
        String name = ftpPath.substring(index + 1);
        return uploadFile(path, name, input);
    }

    // 创建子目录
    private boolean makeDirectory(String dir, FTPClient ftpClient)  throws Exception {
        return ftpClient.makeDirectory(dir);
    }

    // 改变目录的顶级路劲
    private void changeWorkingDirectory(String directory, FTPClient ftpClient) throws Exception {
        boolean qhml = ftpClient.changeWorkingDirectory(directory);
        System.out.println("切换目录:"+qhml);
    }

    /**
     * 删除目录下所有文件
     * @param ftpClient
     * @param path
     * @param isAll
     * @return
     * @throws IOException
     */
    public boolean removeDirectory(FTPClient ftpClient,String path, boolean isAll) throws IOException{
        if (!isAll) {
            return ftpClient.removeDirectory(path);
        }
        FTPFile[] ftpFileArr = ftpClient.listFiles(path);
        if (ftpFileArr == null || ftpFileArr.length == 0) {
            return ftpClient.removeDirectory(path);
        }

        for (FTPFile ftpFile : ftpFileArr) {
            String name = ftpFile.getName();
            if (ftpFile.isDirectory()) {
                removeDirectory(ftpClient,path + "/" + name, true);
            } else if (ftpFile.isFile()) {
                ftpClient.deleteFile(path + "/" + name);
            }
        }
        return ftpClient.removeDirectory(path);
    }

    /**
     * 删除服务器上的文件
     *  @param ftpClient
     * @param pathName
     * @return
     * @throws IOException
     */
    public boolean deleteFile(FTPClient ftpClient,String pathName) throws IOException {
        return ftpClient.deleteFile(pathName);
    }

    /**
     * 解析上传路径，创建DIRS的路径中的所有目录
     *
     * @param path
     * @param ftpClient
     * @return
     * @throws Exception
     */
    private boolean createDir(String path, FTPClient ftpClient) throws Exception {
        String dir = new File(path).getParentFile().getPath();
        if (!ftpClient.changeWorkingDirectory(dir)) {
            String[] dirs = dir.replace("\\", "/").split("/");
            String dir_tem = "";
            for (int i = 0; i < dirs.length; i++) {
                if (dirs[i]==null||dirs[i].trim().length() < 1) {
                    continue;
                }
                dir_tem += "/" + dirs[i];
                makeDirectory(dir_tem, ftpClient);
            }
        }
        changeWorkingDirectory("/", ftpClient);// 回到FTP根目录
        return true;
    }
    /**
     * 切换目录
     * @param path \test\aaa\
     * @param ftpClient
     * @throws IOException
     */
    private void changeMakeWorkingDir(String path, FTPClient ftpClient) throws IOException {
        String reg = File.separator.equals("\\") ? "\\\\" : "/";
        //String[] dirs = path.split("/");//\test\aaa\这个没能拆分   但是有时候就算没拆分 在ftp服务器上的路径还是对的
        String[] dirs = path.split(reg);
        for (String dir : dirs) {
            if("".equals(dir.trim())) continue;
            //dir = new String(dir.getBytes("GBK"), StandardCharsets.ISO_8859_1);
            dir = new String(dir.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1);
            //此处中文是乱码,但是创建好之后是正常的
            if (!"".equals(dir)) {
                ftpClient.makeDirectory(dir);//没有就创建目录返回true；已经有了就不创建了，返回fasle
                //ftpClient.cdUp();//当前目录上移一层。
            }
            ftpClient.changeWorkingDirectory(dir);//切换到指定目录
        }
    }

    /**
     * 下载并转换为base64
     *
     * @param ftpPath
     * @param wjmc
     * @return
     * @throws Exception
     */
    public String getBase64ByFtpUrl(String ftpPath, String wjmc) throws Exception {
        FTPClient ftpClient = new FTPClient();
        InputStream inputStream = null;
        String re = "";
        try {
            ftpClient.connect(ip, port);
            ftpClient.login(user, pwd);
            ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
            ftpClient.enterLocalPassiveMode();
            ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
            ftpClient.setControlEncoding("UTF-8");
            //是否成功登录服务器
            int reply = ftpClient.getReplyCode();
            if (!FTPReply.isPositiveCompletion(reply)) {
                ftpClient.disconnect();
            }
            ftpClient.changeWorkingDirectory(ftpPath);//转移到FTP服务器目录
            FTPFile[] fs = ftpClient.listFiles();
            //System.out.println("---size: "+fs.length);
            // 不需要遍历，改为直接用文件名取  缺陷:filezilla时这个中文文件名处理好像有问题,导致inputStream为null
            String remoteAbsoluteFile = toFtpFilename(ftpPath + wjmc);
            inputStream = ftpClient.retrieveFileStream(remoteAbsoluteFile);

            //这个地方应该是重复编码了吧 ? 直接用上面一个测试
            //inputStream = ftpClient.retrieveFileStream(new String(remoteAbsoluteFile.getBytes("UTF-8"), "ISO-8859-1"));

            /*for (FTPFile ff : fs) {
                //解决中文乱码问题，两次解码
                byte[] bytes = ff.getName().getBytes("iso-8859-1");
                String fileName = new String(bytes, "utf-8");
                System.out.println(fileName);
                if (wjmc.equals(fileName)) {
                    //inputStream = ftpClient.retrieveFileStream(fileName);
                    inputStream = ftpClient.retrieveFileStream(new String(fileName.getBytes("gbk"), "ISO-8859-1"));
                }
            }*/
            if (inputStream != null) {
                //上面这两个转换不完整
                /*byte[] data=new byte[inputStream.available()];
                BASE64Encoder encoder=new BASE64Encoder();
                re=encoder.encode(data);*/
                /*byte[] buffer = new byte[inputStream.available()];
                inputStream.read(buffer);
                inputStream.close();
                re = new BASE64Encoder().encode(buffer);*/
                //下面这个测试成功
                ByteArrayOutputStream outStream = new ByteArrayOutputStream();
                byte[] buffer = new byte[1024];
                outStream.toByteArray();
                int len = 0;
                while ((len = inputStream.read(buffer)) != -1) {
                    outStream.write(buffer, 0, len);
                }
                byte[] data = outStream.toByteArray();
                re = new BASE64Encoder().encode(data);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (ftpClient.isConnected()) {
                try {
                    ftpClient.disconnect();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (null != inputStream) {
                try {
                    inputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return re;
    }

    public String getBase64ByFtpUrl(FTPClient ftpClient, String ftpPath, String wjmc) throws Exception {
        if (ftpClient == null || !ftpClient.isConnected()) {
            throw new Exception("FTP连接失败！");
        }
        InputStream inputStream = null;
        String re = "";
        ftpClient.setBufferSize(1024);
        ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
        ftpClient.enterLocalPassiveMode();
        ftpClient.setFileTransferMode(FTP.STREAM_TRANSFER_MODE);
        ftpClient.setControlEncoding("UTF-8");
        ftpPath = new String(ftpPath.getBytes("UTF-8"), "iso-8859-1");
        try {
            //是否成功登录服务器
            int reply = ftpClient.getReplyCode();
            if (!FTPReply.isPositiveCompletion(reply)) {
                ftpClient.disconnect();
            }
            ftpClient.changeWorkingDirectory(ftpPath);//转移到FTP服务器目录
            FTPFile[] fs = ftpClient.listFiles();
            //System.out.println("---size: "+fs.length);
            // 不需要遍历，改为直接用文件名取
            //String remoteAbsoluteFile = toFtpFilename(ftpPath + wjmc);
            //inputStream = ftpClient.retrieveFileStream(remoteAbsoluteFile);
            //inputStream = ftpClient.retrieveFileStream(new String(remoteAbsoluteFile.getBytes("UTF-8"), "ISO-8859-1"));
            for (FTPFile ff : fs) {
                //解决中文乱码问题，两次解码
                byte[] bytes = ff.getName().getBytes("iso-8859-1");
                String fileName = new String(bytes, "utf-8");
                System.out.println(fileName);
                if (wjmc.equals(fileName)) {
                    //inputStream = ftpClient.retrieveFileStream(fileName);
                    inputStream = ftpClient.retrieveFileStream(new String(fileName.getBytes("gbk"), "ISO-8859-1"));
                }
            }
            if (inputStream != null) {
                //这个流读取不完整
                /*byte[] buffer = new byte[inputStream.available()];
                inputStream.read(buffer);
                inputStream.close();
                re = new BASE64Encoder().encode(buffer);*/
                ByteArrayOutputStream outStream = new ByteArrayOutputStream();
                byte[] buffer = new byte[1024];
                outStream.toByteArray();
                int len = 0;
                while ((len = inputStream.read(buffer)) != -1) {
                    outStream.write(buffer, 0, len);
                }
                byte[] data = outStream.toByteArray();
                re = new BASE64Encoder().encode(data);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (null != inputStream) {
                try {
                    inputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (ftpClient != null && ftpClient.isConnected()) {
                ftpClient.changeToParentDirectory();
                //连续读取文件  必须加   否则就需要每次获取FTPClient
                ftpClient.completePendingCommand();
            }
        }
        return re;
    }
    /**
     * 根据路径删除FTP文件
     * @param ftpPaths
     */
    public static void delFtpFiles(List<String> ftpPaths) {
        if (ftpPaths != null) {
            FtpUtils ftpUtil = new FtpUtils();
            FTPClient ftpClient = null;
            try {
                ftpClient = ftpUtil.getFTPClient();
                for (String path : ftpPaths) {
                    //ftpClient.deleteFile("/ftp-upload/lxcl/2021/06/20/0000002dc-7b82-4b2a-8ef6-58481ac327d0/04983b5b7-aa39-44ca-a327-8a350e0ccfff/0afa3e466-c66c-43ea-a078-ac154d744b50.tif");
                    ftpClient.deleteFile(path);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    /**
     * 获取符合条件的FTP文件
     * @param ftpDir
     * @param limit
     * @param wjgs
     * @param contains
     * @param sjjds
     * @param reg
     * @return
     */
    public List<String> getFtpFiles(String ftpDir, int limit, String wjgs, String contains, String sjjds, String reg) {
        List<String> list = new ArrayList<>();
        FTPClient ftpClient = new FTPClient();
        try {
            ftpClient = getFTPClient();
            //跳转到指定目录
            ftpClient.changeWorkingDirectory(ftpDir);
            //5.遍历下载的目录
            FTPFile[] fs = ftpClient.listFiles();
            list = Arrays.stream(fs).sorted((o1, o2) -> {
                        Map<String, String> elements1 = StringUtil.getContents(CommonProperties.FILENAME_TYREG, o1.getName());
                        int sjjd1 = elements1.get("sjjd") == null ? 0 : Integer.parseInt(elements1.get("sjjd"));
                        Map<String, String> elements2 = StringUtil.getContents(CommonProperties.FILENAME_TYREG, o2.getName());
                        int sjjd2 = elements2.get("sjjd") == null ? 0 : Integer.parseInt(elements2.get("sjjd"));
                        return sjjd1 - sjjd2;
                    })
                    //.sorted((f1, f2) -> Integer.parseInt(String.valueOf(f1.getSize() - f2.getSize())))
                    .filter(ff -> {
                        String fileName;
                        try {
                            fileName = toFtpFilename(ff.getName());
                            if (wjgs != null && !"".equals(wjgs)) {
                                if (!fileName.endsWith(wjgs)) {
                                    return false;
                                }
                            }
                            if (contains != null && !"".equals(contains)) {
                                if (!fileName.contains(contains)) {
                                    return false;
                                }
                            }
                            if (sjjds != null && !"".equals(sjjds)) {
                                Map<String, String> elements = StringUtil.getContents(CommonProperties.FILENAME_TYREG, fileName);
                                String sjjd = elements.get("sjjd") == null ? "" : elements.get("sjjd");
                                if (!sjjds.contains(sjjd)) {
                                    return false;
                                }
                            }
                            if (reg != null && !"".equals(reg)) {
                                if (!StringUtil.matcher(reg, fileName)) {
                                    return false;
                                }
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        return true;
                    }).limit(limit)
                    .map(FTPFile::getName)
                    .collect(Collectors.toList());
            ftpClient.logout();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (ftpClient.isConnected()) {
                try {
                    ftpClient.disconnect();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return list;
    }
    /**
     * 转化输出的编码
     */
    private static String toFtpFilename(String fileName) throws Exception {
        //return new String(fileName.getBytes("GBK"), "ISO8859-1");
        return new String(fileName.getBytes("GBK"), "ISO8859-1");
    }

    public static void main(String[] args) throws Exception {
        String str = "";
        String uploadPath = "";
        FtpUtils ftpUtil = new FtpUtils();
        //编码转换测试
        //String str1 = ftpUtil.getBase64ByFtpUrl("/", "(2018)渝0103民初24388号.jpg");
        //str = ftpUtil.getBase64ByFtpUrl("/", "test.jpg");
        //下载测试
        //ftpUtil.download("/", "(2018)渝0103民初24388号.jpg", "E:\\test\\1111\\(2018)渝0103民初243883号.jpg");
        //ftpUtil.downloadFtpFile("/", "(2018)渝0103民初9824号.jpg", "E:\\test\\1111");
        //ftpUtil.downloadFtpFile("/", "hcbg.jpg", "E:\\test\\1111");
        //上传测试
        //File file = new File("E:\\xfUploaod_ywj\\(2018)法网信字第0000056号\\2018-03-27\\核查报告\\hcbg.jpg");
        //FileInputStream in = new FileInputStream(file);
        //ftpUtil.uploadFile(File.separator, "hcbg_upload.jpg", in);
        //如果ftp中文路径  需要修改
        //uploadPath = ftpUtil.uploadLocalFile(File.separator + "test" + File.separator+"测试测试"+File.separator, "hcbg_中文.jpg", "E:\\xfUploaod_ywj\\(2018)法网信字第0000056号\\2018-03-27\\核查报告\\hcbg.jpg");
        //uploadPath = ftpUtil.uploadLocalFile(File.separator + "test" + File.separator+"aaa"+File.separator, "hcbg_23.jpg", "E:\\xfUploaod_ywj\\(2018)法网信字第0000056号\\2018-03-27\\起诉书\\(2018)渝0103民初9824号.jpg");
        //uploadPath = ftpUtil.uploadLocalFile(File.separator + "test" + File.separator+"测试测试"+File.separator, "hcbg_中文.jpg", "E:\\xfUploaod_ywj\\(2018)法网信字第0000056号\\2018-03-27\\核查报告\\hcbg.jpg");
        ftpUtil.uploadLocalFile("/test/222/333.png", "E:\\xfUploaod_ywj\\(2014)法信字第10067号\\2013-01-20\\申请材料\\2020-ZGFX-17097-0001.tif");
        System.out.println(str);
        System.out.println(uploadPath);



    }
}